﻿using Abp.Configuration.Startup;
using Castle.Core;

namespace AbpProjectTemplate.Components.Configuration
{
    public static class AutoSettingsManager
    {
        public static void AddAutoSettings(this IAbpStartupConfiguration configuration)
        {
            configuration.IocManager.IocContainer.Kernel.ComponentRegistered += (key, handler) =>
            {
                if (typeof(IAutoSettings).IsAssignableFrom(handler.ComponentModel.Implementation))
                {
                    handler.ComponentModel.Interceptors.Add(new InterceptorReference(typeof(AutoSettingsInterceptor)));
                }
            };


            configuration.Settings.Providers.Add<AutoSettingsProvider>();
        }
    }
}
